Skip to main content

Liveness & Readiness

After filling in details regarding Access level, Resource Quota, Configurations, Secrets & PVC, Environment Variables and Node & Service Affinity, you can also specify Liveness and Readiness details. Providing information regarding Liveness and Readiness is not mandatory. It is completely optional to fill in details for this section.

Both liveness and readiness probes are used by container orchestration systems, such as Kubernetes, to monitor and manage the health of applications running in containers.

What is Liveness?#

Liveness refers to the ability of an application or service to respond to requests and continue to function properly.

A Liveness Probe indicates if the container is operating. If so, no action is taken. If the container is not working, kubelet kills and restarts the container.

For example, a liveness probe might check whether an application's HTTP endpoint is responding with a 200 OK status code. If an application fails the liveness probe, it is considered to be in a failed state and may be restarted or terminated.

What is Readiness?#

Readiness, on the other hand, refers to the ability of an application or service to accept traffic and handle requests.

A Readiness Probe indicates whether the application running in the container is ready to accept requests. If so, services matching the pod are allowed to send traffic to the application. If not, the endpoints controller removes the pod from all matching Kubernetes Services.

For example, a readiness probe might check whether an application has finished initializing its database connections and is able to handle requests. If an application fails the readiness probe, it is considered to be not ready to accept traffic and may be removed from load balancers until it becomes ready again.

Configuration of Liveness and Readiness Probe#

Configuring a liveness and readiness probe in Kubernetes involves setting the following parameters:

  • Probe Type: The type of probe can be HTTP, TCP, or Command. HTTP probes send an HTTP GET request to the specified endpoint, while TCP probes attempt to establish a connection to the specified port. Command probes execute a command inside the container to determine its health status.
  • Probe Endpoint or Port: The endpoint or port that the probe should check to determine if the container is alive and ready to receive traffic.
  • Probe Path or Command: The path or command that the probe should use to determine the health of the container. For example, for an HTTP probe, this would be the URL path that should return a 200 OK status code.
  • Initial Delay Seconds: Defines the delay between the time the container starts and the first time the probe is executed.
  • Period Seconds: Defines how frequently the probe will be executed after the initial delay.
  • Timeout Seconds: The amount of time to wait for a response before considering the probe to have failed. Each probe will time out and be marked as failed after these many seconds.
  • Failure Threshold: Instructs Kubernetes to retry the probe this many times after a failure is first recorded. The container will only be restarted and considered as unhealthy, if the retries also fail.
  • Success Threshold: This sets the criteria for reverting an unhealthy container to a healthy state. It means the container must successfully pass this number of consecutive liveness checks before it’s considered healthy again.

By configuring these parameters, Kubernetes can ensure that only healthy containers are used to serve traffic, improving the reliability and availability of your applications.

Set Liveness Probe#

Here's how you can set a Liveness Probe to monitor the health of your applications.

  • Click “Yes” if you have a Liveness health check URL else click “No”
  • Choose the execution type for setting a Liveness probe. Either select URL/Path or enter a Command.
  • If you choose to enter URL/Path, then specify the port which the probe should check to determine if the container is alive and functioning properly.
  • If you choose Command type, then enter the Command that the probe should use to determine the health of the container.
  • Enter Liveness time settings which include specifying,
    • Delay seconds
    • Period seconds
    • Timeouts seconds
    • Failure threshold

Docs Version Dropdown

Set Readiness Probe#

Here's how you can set a Readiness Probe to monitor the health of your applications.

  • Click “Yes” if you have a Readiness health check URL else click “No”
  • Choose the execution type for setting a Readiness probe. Either select URL/Path or enter a Command.
  • If you choose to enter URL/Path, then specify the port which the probe should check to determine if the container is ready to receive traffic.
  • If you choose command type, then enter the command that the probe should use to determine the health of the container
  • Enter Readiness time settings which include specifying,
    • Delay seconds
    • Period seconds
    • Timeouts seconds
    • Failure threshold

Docs Version Dropdown